package com.dragon.mmochat.service;

import java.io.File;
import java.text.ParseException;
import java.util.Date;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.MmochatMain;
import com.dragon.mmochat.model.activity.MmochatDaoActivity;
import com.dragon.mmochat.model.activity.MmochatDoubleAwardActivity;
import com.dragon.mmochat.model.activity.MmochatFastLotteryAward;
import com.dragon.mmochat.model.activity.MmochatFastLotteryAwardTitle;
import com.dragon.mmochat.model.activity.MmochatFirstPayAwardInfo;
import com.dragon.mmochat.model.activity.MmochatPayAwardActivity;
import com.dragon.mmochat.model.activity.MmochatPayFastLotteryInfo;
import com.dragon.mmochat.model.activity.MmochatPayLotteryInfo;
import com.dragon.mmochat.model.activity.OnlineAwardInfo;
import com.dragon.mmochat.model.award.MmochatBigMoneyAward;
import com.dragon.mmochat.model.award.MmochatEquipAward;
import com.dragon.mmochat.model.award.MmochatPropAward;
import com.dragon.mmochat.model.enumType.MmochatEquipQualityType;
import com.dragon.mmochat.model.enumType.MmochatEquipType;
import com.dragon.mmochat.model.enumType.MmochatMoneyType;
import com.dragon.mmochat.model.enumType.MmochatPayLotteryState;
import com.dragon.mmochat.model.enumType.MmochatPropType;
import com.dragon.mmochat.model.enumType.MmochatRoleBmpType;
import com.dragon.mmochat.model.enumType.MmochatServerType;
import com.dragon.mmochat.model.enumType.MmochatTaskType;
import com.dragon.mmochat.model.role.MmochatActivityNpc;
import com.dragon.mmochat.model.scheduleJob.ActivitiesNpcJob;
import com.dragon.mmochat.model.scheduleJob.CommonSystemMsgJob;
import com.dragon.mmochat.model.scheduleJob.DaoActivityJob;
import com.dragon.mmochat.model.scheduleJob.DoubleAwardActivityJob;
import com.dragon.mmochat.model.scheduleJob.FastPayLotteryJob;
import com.dragon.mmochat.model.scheduleJob.FirstPayAwardJob;
import com.dragon.mmochat.model.scheduleJob.Hourly_TimeMonster;
import com.dragon.mmochat.model.scheduleJob.OnlineAwardActivityJob;
import com.dragon.mmochat.model.scheduleJob.PayAwardJob;
import com.dragon.mmochat.model.scheduleJob.PayLotteryJob;
import com.dragon.mmochat.model.scheduleJob.multiServer.MultiServerLeiTai_Clear;
import com.dragon.mmochat.model.scheduleJob.multiServer.MultiServerWuDao_End;
import com.dragon.mmochat.model.scheduleJob.multiServer.MultiServerWuDao_Prepare;
import com.dragon.mmochat.model.scheduleJob.multiServer.MultiServerWuDao_Start;
import com.dragon.mmochat.model.scheduleJob.pkGame.EndPkGame;
import com.dragon.mmochat.model.scheduleJob.pkGame.PreparePkGame;
import com.dragon.mmochat.model.scheduleJob.pkGame.StartPkGame;
import com.dragon.mmochat.model.serverListDao.job.calNewRegSkyIdJob;
import com.dragon.mmochat.model.task.MmochatNpcBattle;

//定时任务
public class MmochatScheduleJobService {
	private static Logger log = LoggerFactory
			.getLogger(MmochatScheduleJobService.class);

	public static ScheduledExecutorService es = Executors
			.newScheduledThreadPool(1);
	public static Scheduler sched = null;
	private static Map<String, String> jobInfos = new ConcurrentHashMap<String, String>();

	@SuppressWarnings("deprecation")
	public void init() {
		if (!MmochatMain.openMergeServer) {
			log.debug("init MmochatScheduleJobService");
			loadActivitiesReal();

			// 每天3点重新加载activities下的活动
			Date now = new Date();
			int hour = now.getHours();
			int minutes = now.getMinutes();
			int sec = now.getSeconds();
			int startTime = (int) ((60 - sec) + (60 - minutes - 1)
					* MmochatConstant.SECOND_PER_MIN + (3 - hour - 1)
					* MmochatConstant.SECOND_PER_HOUR);
			if (startTime <= 0) {
				startTime += MmochatConstant.SECOND_PER_DAY;
			}
			es.scheduleWithFixedDelay(new loadActivities(), startTime,
					MmochatConstant.SECOND_PER_DAY, TimeUnit.SECONDS);
		}
	}

	class loadActivities implements Runnable {
		public void run() {
			try {
				MmochatConstant.isShopDiscountActivityOpen = false;
				loadActivitiesReal();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	private static void loadActivitiesReal() {
		try {
			// 通过创建SchedulerFactory 来创建Scheduler 实例
			if (sched != null) {
				// deleteJob(jobName, groupName)
				// Delete the identified Job from the Scheduler - and any
				// associated Triggers.
				for (Entry<String, String> entry : jobInfos.entrySet()) {
					String jobName = entry.getKey();
					String group = entry.getValue();
					try {
						sched.deleteJob(jobName, group);
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				jobInfos.clear();
			} else {
				SchedulerFactory sf = new StdSchedulerFactory();
				sched = sf.getScheduler();
			}
			if (MmochatMain.serverType == MmochatServerType.游戏服务器) {
				/***************** 各类活动系统公告(仅限于触发时间为0/10/20/30/40/50分的活动) *****************/
				try {
					// 通过JobDetail，将定时程序做为quartz job
					JobDetail job = new JobDetail("timeSystemMsg",
							"timeSystemMsgGroup", CommonSystemMsgJob.class);
					jobInfos.put("timeSystemMsg", "timeSystemMsgGroup");

					// 创建trigger,触发定时程序
					CronTrigger trigger = new CronTrigger();
					trigger.setName("timeSystemMsgTrigger");
					try {
						trigger.setCronExpression("0 0/10 * * * ?");
					} catch (ParseException e) {
						e.printStackTrace();
					}

					// 通过trigger 调度job
					sched.scheduleJob(job, trigger);
				} catch (Exception e1) {
					e1.printStackTrace();
				}

				/***************** 蒲牢十子任务(整点半触发) *****************/
				try {
					// 通过JobDetail，将定时程序做为quartz job
					JobDetail job = new JobDetail("timeMonster",
							"timeMonsterGroup", Hourly_TimeMonster.class);
					jobInfos.put("timeMonster", "timeMonsterGroup");

					// 创建trigger,触发定时程序
					CronTrigger trigger = new CronTrigger();
					trigger.setName("timeMonsterTrigger");
					try {
						trigger.setCronExpression("0 30 * * * ?");
					} catch (ParseException e) {
						e.printStackTrace();
					}

					// 通过trigger 调度job
					sched.scheduleJob(job, trigger);
				} catch (Exception e1) {
					e1.printStackTrace();
				}

				/***************** 每天19:40准备活动地图 *****************/
				try {
					// 通过JobDetail，将定时程序做为quartz job
					JobDetail job = new JobDetail("准备活动地图", "每日活动",
							PreparePkGame.class);
					jobInfos.put("准备活动地图", "每日活动");

					// 创建trigger,触发定时程序
					CronTrigger trigger = new CronTrigger();
					trigger.setName("准备活动地图Trigger");
					try {
						trigger.setCronExpression("0 40 19 * * ?");
					} catch (ParseException e) {
						e.printStackTrace();
					}

					// 通过trigger 调度job
					sched.scheduleJob(job, trigger);
				} catch (Exception e1) {
					e1.printStackTrace();
				}

				/***************** 每天22:00关闭活动地图 *****************/
				try {
					// 通过JobDetail，将定时程序做为quartz job
					JobDetail job = new JobDetail("关闭活动地图", "每日活动",
							EndPkGame.class);
					jobInfos.put("关闭活动地图", "每日活动");

					// 创建trigger,触发定时程序
					CronTrigger trigger = new CronTrigger();
					trigger.setName("关闭活动地图Trigger");
					try {
						trigger.setCronExpression("0 0 22 * * ?");
					} catch (ParseException e) {
						e.printStackTrace();
					}

					// 通过trigger 调度job
					sched.scheduleJob(job, trigger);
				} catch (Exception e1) {
					e1.printStackTrace();
				}

				/***************** 每天20:00:30开始活动 *****************/
				try {
					// 通过JobDetail，将定时程序做为quartz job
					JobDetail job = new JobDetail("开始每日活动", "每日活动",
							StartPkGame.class);
					jobInfos.put("开始每日活动", "每日活动");

					// 创建trigger,触发定时程序
					CronTrigger trigger = new CronTrigger();
					trigger.setName("开始每日活动Trigger");
					try {
						trigger.setCronExpression("30 0 20 * * ?");
					} catch (ParseException e) {
						e.printStackTrace();
					}

					// 通过trigger 调度job
					sched.scheduleJob(job, trigger);
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}

			/******************* 跨服服务器 ******************/
			if (MmochatMain.serverType == MmochatServerType.跨服战服务器) {
				// 擂台清人:每天19:00清场
				try {
					// 通过JobDetail，将定时程序做为quartz job
					JobDetail job = new JobDetail("跨服擂台清场", "跨服擂台活动",
							MultiServerLeiTai_Clear.class);
					jobInfos.put("跨服擂台清场", "跨服擂台活动");

					// 创建trigger,触发定时程序
					CronTrigger trigger = new CronTrigger();
					trigger.setName("跨服擂台清场Trigger");
					try {
						trigger.setCronExpression("0 0 19 * * ?");
					} catch (ParseException e) {
						e.printStackTrace();
					}

					// 通过trigger 调度job
					sched.scheduleJob(job, trigger);
				} catch (Exception e1) {
					e1.printStackTrace();
				}

				// 跨服武道:周四19:30-20:00入场；20:00-22:00结束；
				/***************** 每周四19:30准备活动地图 *****************/
				try {
					// 通过JobDetail，将定时程序做为quartz job
					JobDetail job = new JobDetail("准备跨服武道", "跨服活动",
							MultiServerWuDao_Prepare.class);
					jobInfos.put("准备跨服武道", "跨服活动");
					job.getJobDataMap().put("team", 1);

					// 创建trigger,触发定时程序
					CronTrigger trigger = new CronTrigger();
					trigger.setName("准备跨服武道Trigger");
					try {
						trigger.setCronExpression("0 30 19 ? * THU");
					} catch (ParseException e) {
						e.printStackTrace();
					}

					// 通过trigger 调度job
					sched.scheduleJob(job, trigger);
				} catch (Exception e1) {
					e1.printStackTrace();
				}

				/***************** 每天20:00:30开始活动 *****************/
				try {
					// 通过JobDetail，将定时程序做为quartz job
					JobDetail job = new JobDetail("开始跨服武道", "跨服活动",
							MultiServerWuDao_Start.class);
					jobInfos.put("开始跨服武道", "跨服活动");
					job.getJobDataMap().put("team", 1);

					// 创建trigger,触发定时程序
					CronTrigger trigger = new CronTrigger();
					trigger.setName("开始跨服武道Trigger");
					try {
						trigger.setCronExpression("30 0 20 ? * THU");
					} catch (ParseException e) {
						e.printStackTrace();
					}

					// 通过trigger 调度job
					sched.scheduleJob(job, trigger);
				} catch (Exception e1) {
					e1.printStackTrace();
				}

				/***************** 每天22:00关闭活动地图 *****************/
				try {
					// 通过JobDetail，将定时程序做为quartz job
					JobDetail job = new JobDetail("关闭跨服武道", "跨服活动",
							MultiServerWuDao_End.class);
					jobInfos.put("关闭跨服武道", "跨服活动");
					job.getJobDataMap().put("team", 1);

					// 创建trigger,触发定时程序
					CronTrigger trigger = new CronTrigger();
					trigger.setName("关闭跨服武道Trigger");
					try {
						trigger.setCronExpression("0 0 22 ? * THU");
					} catch (ParseException e) {
						e.printStackTrace();
					}

					// 通过trigger 调度job
					sched.scheduleJob(job, trigger);
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}

			if (MmochatMain.moduleInstID == MmochatConstant.serverListModuleId) {
				// 列表服务器
				try {
					// 通过JobDetail，将定时程序做为quartz job
					JobDetail job = new JobDetail("列表服务器统计", "数据统计",
							calNewRegSkyIdJob.class);
					jobInfos.put("列表服务器统计", "数据统计");

					// 创建trigger,触发定时程序
					CronTrigger trigger = new CronTrigger();
					trigger.setName("列表服务器统计Trigger");
					try {
						trigger.setCronExpression("0 0 0 * * ?");
					} catch (ParseException e) {
						e.printStackTrace();
					}

					// 通过trigger 调度job
					sched.scheduleJob(job, trigger);
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}

			/***************** 读取[activities/怪物NPC活动]目录下的所有定时任务 *****************/
			try {
				File root = new File("activities/npcActivity");
				File[] files = root.listFiles();
				if (files != null) {
					for (File file : files) {
						if (!file.isFile()) {
							continue;
						}
						DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
								.newInstance();
						DocumentBuilder docBuilder = docBuilderFactory
								.newDocumentBuilder();
						Document doc = docBuilder.parse(file);
						doc.getDocumentElement().normalize();
						NodeList listOfNpc = doc
								.getElementsByTagName("MmochatActivityNpc");
						log.debug("MmochatActivityNpc num = "
								+ listOfNpc.getLength());

						for (int s = 0; s < listOfNpc.getLength(); s++) {
							Node firstNpcNode = listOfNpc.item(s);
							if (firstNpcNode.getNodeType() == Node.ELEMENT_NODE) {
								MmochatActivityNpc activityNpc = new MmochatActivityNpc();
								Element firstNpcElement = (Element) firstNpcNode;
								// 读取name
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("name");
									String str = node.item(0).getChildNodes()
											.item(0).getNodeValue().trim();
									activityNpc.setName(str);
								}
								// 读取minLevelToBeat
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("minLevelToBeat");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int num;
										try {
											num = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，MmochatActivityNpc的minLevelToBeat不是数字,name="
															+ activityNpc
																	.getName());
										}
										activityNpc.setMinLevel(num);
									}
								}
								// 读取maxLevelToBeat
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("maxLevelToBeat");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int num;
										try {
											num = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，MmochatActivityNpc的maxLevelToBeat不是数字,name="
															+ activityNpc
																	.getName());
										}
										activityNpc.setMaxLevel(num);
									}
								}
								// 读取bmp
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("bmp");
									String str = node.item(0).getChildNodes()
											.item(0).getNodeValue().trim();
									activityNpc.setBmpType(MmochatRoleBmpType
											.valueOf(str));
								}
								// 读取life
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("life");
									String str = node.item(0).getChildNodes()
											.item(0).getNodeValue().trim();
									int num;
									try {
										num = Integer.parseInt(str);
									} catch (Exception e) {
										e.printStackTrace();
										throw new RuntimeException(
												"加载"
														+ file.getName()
														+ "时，MmochatActivityNpc的life不是数字,name="
														+ activityNpc.getName());
									}
									activityNpc.setLifeTime(num);
								}
								// 读取appearTime
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("appearTime");
									String str = node.item(0).getChildNodes()
											.item(0).getNodeValue().trim();
									activityNpc.setAppearTime(str);
								}
								// 读取systemMsg
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("systemMsg");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										activityNpc.setSystemMsg(str);
									}
								}
								// 读取appearMap
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("appearMap");
									String str = node.item(0).getChildNodes()
											.item(0).getNodeValue().trim();
									String[] numStr = str.split(",");
									int num;
									for (int i = 0; i < numStr.length; i++) {
										if (numStr[i] == "") {
											continue;
										}
										try {
											num = Integer.parseInt(numStr[i]);
											activityNpc.addAppearMap(num);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，MmochatActivityNpc的appearMap不是数字,name="
															+ activityNpc
																	.getName());
										}
									}
								}
								// 读取isAppearInAllMap
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("isAppearInAllMap");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										if (str.equals("false")) {
											activityNpc
													.setAppearInAllMap(false);
										}
									}
								}
								// 读取appearNum
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("appearNum");
									String str = node.item(0).getChildNodes()
											.item(0).getNodeValue().trim();
									int num;
									try {
										num = Integer.parseInt(str);
									} catch (Exception e) {
										e.printStackTrace();
										throw new RuntimeException(
												"加载"
														+ file.getName()
														+ "时，MmochatActivityNpc的appearNum不是数字,name="
														+ activityNpc.getName());
									}
									activityNpc.setAppearNum(num);
								}

								// 读取minTeamNum
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("minTeamNum");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int num;
										try {
											num = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，MmochatActivityNpc的minTeamNum不是数字,name="
															+ activityNpc
																	.getName());
										}
										activityNpc.setMinTeamNum(num);
									}
								}

								// 读取taskType
								activityNpc
										.setBattleType(MmochatTaskType.击杀活动怪物);

								// 读取money
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("money");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int num;
										try {
											num = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，MmochatActivityNpc的money不是数字,name="
															+ activityNpc
																	.getName());
										}
										activityNpc.setMoney(num);
									}
								}
								// 读取exp
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("经验倍数");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int num;
										try {
											num = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，MmochatActivityNpc的经验倍数不是数字,name="
															+ activityNpc
																	.getName());
										}
										activityNpc.setExp(num);
									}
								}

								// 读取dao
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("dao");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int num;
										try {
											num = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，MmochatActivityNpc的dao不是数字,name="
															+ activityNpc
																	.getName());
										}
										activityNpc.setDao(num);
									}
								}

								// 读取zhangJi
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("zhangJi");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int num;
										try {
											num = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，MmochatActivityNpc的zhangJi不是数字,name="
															+ activityNpc
																	.getName());
										}
										activityNpc.setZhangJi(num);
									}
								}

								// 读取willKillPlayer
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("玩家战败死亡");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										if (str.equals("否")) {
											activityNpc
													.setWillKillPlayer(false);
										} else {
											activityNpc.setWillKillPlayer(true);
										}
									} else {
										activityNpc.setWillKillPlayer(true);
									}
								}

								// 读取道具奖励
								NodeList propList = firstNpcElement
										.getElementsByTagName("prop");
								for (int index = 0; index < propList
										.getLength(); index++) {
									Node propNode = propList.item(index);
									if (propNode.getNodeType() == Node.ELEMENT_NODE) {
										Element propElement = (Element) propNode;
										MmochatPropAward prop = new MmochatPropAward();
										// 读取opportunity
										{
											NodeList node = propElement
													.getElementsByTagName("opportunity");
											if (node != null
													&& node.getLength() > 0) {
												String str = node.item(0)
														.getChildNodes()
														.item(0).getNodeValue()
														.trim();
												int num;
												try {
													num = Integer.parseInt(str);
												} catch (Exception e) {
													e.printStackTrace();
													throw new RuntimeException(
															"加载"
																	+ file
																			.getName()
																	+ "时，MmochatActivityNpc的prop的opportunity不是数字,name="
																	+ activityNpc
																			.getName());
												}
												if (num == 0) {
													continue;
												}
												prop.setOpportunity(num);
											} else {
												prop.setOpportunity(100);
											}
										}
										// 读取name
										{
											try {
												NodeList node = propElement
														.getElementsByTagName("name");
												String str = node.item(0)
														.getChildNodes()
														.item(0).getNodeValue()
														.trim();
												prop
														.setPropType(MmochatPropType
																.valueOf(str));
											} catch (Exception e) {
												e.printStackTrace();
												throw new RuntimeException(
														"加载"
																+ file
																		.getName()
																+ "时，MmochatActivityNpc的prop-name非法,NPC的name="
																+ activityNpc
																		.getName());
											}
										}
										// 读取canDeal
										{
											try {
												NodeList node = propElement
														.getElementsByTagName("canDeal");
												if (node.getLength() > 0) {
													String str = node.item(0)
															.getChildNodes()
															.item(0)
															.getNodeValue()
															.trim();
													if (str.endsWith("false")) {
														prop.setCanDeal(false);
													} else {
														prop.setCanDeal(true);
													}
												}
											} catch (Exception e) {
												e.printStackTrace();
												throw new RuntimeException(
														"加载"
																+ file
																		.getName()
																+ "时，MmochatActivityNpc的prop-canDeal非法,name="
																+ activityNpc
																		.getName());
											}
										}
										activityNpc.getFinish_award_props()
												.add(prop);
									}
								}

								// 读取装备奖励
								NodeList equipList = firstNpcElement
										.getElementsByTagName("equip");
								for (int index = 0; index < equipList
										.getLength(); index++) {
									Node equipNode = equipList.item(index);
									if (equipNode.getNodeType() == Node.ELEMENT_NODE) {
										Element equipElement = (Element) equipNode;
										MmochatEquipAward equip = new MmochatEquipAward();
										// 读取opportunity
										{
											NodeList node = equipElement
													.getElementsByTagName("opportunity");
											if (node != null
													&& node.getLength() > 0) {
												String str = node.item(0)
														.getChildNodes()
														.item(0).getNodeValue()
														.trim();
												int num;
												try {
													num = Integer.parseInt(str);
												} catch (Exception e) {
													e.printStackTrace();
													throw new RuntimeException(
															"加载"
																	+ file
																			.getName()
																	+ "时，MmochatActivityNpc的equip的opportunity不是数字,name="
																	+ activityNpc
																			.getName());
												}
												if (num == 0) {
													continue;
												}
												equip.setOpportunity(num);
											} else {
												equip.setOpportunity(100);
											}
										}
										// 读取type
										{
											try {
												NodeList node = equipElement
														.getElementsByTagName("type");
												if (node != null
														&& node.getLength() > 0) {
													String str = node.item(0)
															.getChildNodes()
															.item(0)
															.getNodeValue()
															.trim();
													equip
															.setEquipType(MmochatEquipType
																	.valueOf(str));
												} else {
													// 随机类型
													equip
															.setEquipType(MmochatEquipType
																	.getRandomEquipTypeWithoutJewelry());
												}
											} catch (Exception e) {
												e.printStackTrace();
												throw new RuntimeException(
														"加载"
																+ file
																		.getName()
																+ "时，MmochatActivityNpc的equip-type非法,name="
																+ activityNpc
																		.getName());
											}
										}
										// 读取quality
										{
											try {
												NodeList node = equipElement
														.getElementsByTagName("quality");
												String str = node.item(0)
														.getChildNodes()
														.item(0).getNodeValue()
														.trim();
												equip
														.setQuality(MmochatEquipQualityType
																.valueOf(str));
											} catch (Exception e) {
												e.printStackTrace();
												throw new RuntimeException(
														"加载"
																+ file
																		.getName()
																+ "时，MmochatActivityNpc的equip-quality非法,name="
																+ activityNpc
																		.getName());
											}
										}
										// 读取modify
										{
											NodeList node = equipElement
													.getElementsByTagName("modify");
											if (node != null
													&& node.getLength() > 0) {
												String str = node.item(0)
														.getChildNodes()
														.item(0).getNodeValue()
														.trim();
												int num;
												try {
													num = Integer.parseInt(str);
												} catch (Exception e) {
													e.printStackTrace();
													throw new RuntimeException(
															"加载"
																	+ file
																			.getName()
																	+ "时，MmochatActivityNpc的equip的modify不是数字,name="
																	+ activityNpc
																			.getName());
												}
												equip.setModify(num);
											} else {
												equip.setModify(0);
											}
										}
										activityNpc.getFinish_award_equips()
												.add(equip);
									}
								}

								// 读取首饰奖励
								NodeList jewelryList = firstNpcElement
										.getElementsByTagName("jewelry");
								for (int index = 0; index < jewelryList
										.getLength(); index++) {
									Node equipNode = jewelryList.item(index);
									if (equipNode.getNodeType() == Node.ELEMENT_NODE) {
										Element equipElement = (Element) equipNode;
										MmochatEquipAward equip = new MmochatEquipAward();
										equip
												.setQuality(MmochatEquipQualityType.金装);
										// 读取opportunity
										{
											NodeList node = equipElement
													.getElementsByTagName("opportunity");
											if (node != null
													&& node.getLength() > 0) {
												String str = node.item(0)
														.getChildNodes()
														.item(0).getNodeValue()
														.trim();
												int num;
												try {
													num = Integer.parseInt(str);
												} catch (Exception e) {
													e.printStackTrace();
													throw new RuntimeException(
															"加载"
																	+ file
																			.getName()
																	+ "时，MmochatActivityNpc的equip的opportunity不是数字,name="
																	+ activityNpc
																			.getName());
												}
												if (num == 0) {
													continue;
												}
												equip.setOpportunity(num);
											} else {
												equip.setOpportunity(100);
											}
										}
										// 读取name
										{
											try {
												NodeList node = equipElement
														.getElementsByTagName("name");
												if (node != null
														&& node.getLength() > 0) {
													String str = node.item(0)
															.getChildNodes()
															.item(0)
															.getNodeValue()
															.trim();
													equip
															.setEquipType(MmochatEquipType
																	.valueOf(str));
												} else {
													// 随机类型
													equip
															.setEquipType(MmochatEquipType
																	.getRandomJewelryType());
												}
											} catch (Exception e) {
												e.printStackTrace();
												throw new RuntimeException(
														"加载"
																+ file
																		.getName()
																+ "时，MmochatActivityNpc的equip-type非法,name="
																+ activityNpc
																		.getName());
											}
										}
										activityNpc.getFinish_award_equips()
												.add(equip);
									}
								}

								// 读取元宝奖励
								NodeList bigMoneyList = firstNpcElement
										.getElementsByTagName("bigMoney");
								if (bigMoneyList.getLength() > 0) {
									Node bigMoneyNode = bigMoneyList.item(0);
									if (bigMoneyNode.getNodeType() == Node.ELEMENT_NODE) {
										Element bigMoneyElement = (Element) bigMoneyNode;
										MmochatBigMoneyAward bigMoney = new MmochatBigMoneyAward();
										// 读取opportunity
										{
											NodeList node = bigMoneyElement
													.getElementsByTagName("opportunity");
											if (node != null
													&& node.getLength() > 0) {
												String str = node.item(0)
														.getChildNodes()
														.item(0).getNodeValue()
														.trim();
												int num;
												try {
													num = Integer.parseInt(str);
												} catch (Exception e) {
													e.printStackTrace();
													throw new RuntimeException(
															"加载"
																	+ file
																			.getName()
																	+ "时，MmochatActivityNpc的bigMoney的opportunity不是数字,name="
																	+ activityNpc
																			.getName());
												}
												bigMoney.setOpportunity(num);
											}
										}
										// 读取max
										{
											try {
												NodeList node = bigMoneyElement
														.getElementsByTagName("max");
												String str = node.item(0)
														.getChildNodes()
														.item(0).getNodeValue()
														.trim();
												int num;
												num = Integer.parseInt(str);
												bigMoney.setMax(num);
											} catch (Exception e) {
												e.printStackTrace();
												throw new RuntimeException(
														"加载"
																+ file
																		.getName()
																+ "时，MmochatActivityNpc的bigMoney-max非法,name="
																+ activityNpc
																		.getName());
											}
										}
										// 读取min
										{
											try {
												NodeList node = bigMoneyElement
														.getElementsByTagName("min");
												String str = node.item(0)
														.getChildNodes()
														.item(0).getNodeValue()
														.trim();
												int num;
												num = Integer.parseInt(str);
												bigMoney.setMin(num);
											} catch (Exception e) {
												e.printStackTrace();
												throw new RuntimeException(
														"加载"
																+ file
																		.getName()
																+ "时，MmochatActivityNpc的bigMoney-min非法,name="
																+ activityNpc
																		.getName());
											}
										}
										if (bigMoney.getOpportunity() > 0) {
											activityNpc
													.setFinish_award_bigMoney(bigMoney);
										}
									}
								}

								// 读取MmochatMonsterFactory
								NodeList monsterFactory = firstNpcElement
										.getElementsByTagName("battle");
								if (monsterFactory.getLength() > 0) {
									Node monsterFactoryNode = monsterFactory
											.item(0);
									if (monsterFactoryNode.getNodeType() == Node.ELEMENT_NODE) {
										Element monsterFactoryElement = (Element) monsterFactoryNode;
										MmochatNpcBattle battle = MmochatMainService
												.createNpcBattleFromFile(monsterFactoryElement);
										activityNpc.setBattle(battle);
									}

								}
								// 装载定时任务
								JobDetail newJob = new JobDetail(file.getName()
										+ s, "activitiesGroup",
										ActivitiesNpcJob.class);
								jobInfos.put(file.getName() + s,
										"activitiesGroup");

								newJob.getJobDataMap().put("activityNpc",
										activityNpc);

								// 创建trigger,触发定时程序
								CronTrigger newTrigger = new CronTrigger();
								newTrigger.setName(file.getName() + s
										+ "Trigger");
								try {
									newTrigger.setCronExpression(activityNpc
											.getAppearTime());
								} catch (ParseException e) {
									e.printStackTrace();
								}

								// 通过trigger 调度job
								sched.scheduleJob(newJob, newTrigger);
							}
						}
					}
				}
			} catch (SAXParseException err) {
				log.debug("** Parsing error" + ", line " + err.getLineNumber()
						+ ", uri " + err.getSystemId());
				log.debug(" " + err.getMessage());
				err.printStackTrace();
				throw new RuntimeException("LoadActivityEveryDay失败,请重启!");
			} catch (SAXException e) {
				Exception x = e.getException();
				((x == null) ? e : x).printStackTrace();
				throw new RuntimeException("LoadActivityEveryDay失败,请重启!");
			} catch (Throwable t) {
				t.printStackTrace();
				throw new RuntimeException("LoadActivityEveryDay失败,请重启!");
			}

			/************************ 加载[activities/双倍活动]下所有文件 *************************/
			try {

				File root = new File("activities/doubleAward");
				File[] files = root.listFiles();
				if (files != null) {
					for (File file : files) {
						if (!file.isFile()) {
							continue;
						}
						DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
								.newInstance();
						DocumentBuilder docBuilder = docBuilderFactory
								.newDocumentBuilder();
						Document doc = docBuilder.parse(file);
						doc.getDocumentElement().normalize();
						NodeList listOfNpc = doc.getElementsByTagName("双倍活动");
						log.debug("双倍活动 num = " + listOfNpc.getLength());

						for (int s = 0; s < listOfNpc.getLength(); s++) {
							Node firstNpcNode = listOfNpc.item(s);
							if (firstNpcNode.getNodeType() == Node.ELEMENT_NODE) {
								Element firstNpcElement = (Element) firstNpcNode;
								MmochatDoubleAwardActivity start = new MmochatDoubleAwardActivity(
										true);
								MmochatDoubleAwardActivity end = new MmochatDoubleAwardActivity(
										false);
								String startTime = null, endTime = null;
								// 读取开始时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("开始时间");
									if (node != null && node.getLength() > 0) {
										startTime = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
									}
								}
								// 读取结束时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("结束时间");
									if (node != null && node.getLength() > 0) {
										endTime = node.item(0).getChildNodes()
												.item(0).getNodeValue().trim();
									}
								}
								// 读取开始系统消息
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("开始系统消息");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										start.setSystemMsg(str);
									}
								}
								// 读取结束系统消息
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("结束系统消息");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										end.setSystemMsg(str);
									}
								}
								// 装载定时任务
								if (startTime != null && endTime != null) {
									// 开始时间
									JobDetail newJob = new JobDetail(file
											.getName()
											+ s + "start", "activitiesGroup",
											DoubleAwardActivityJob.class);
									jobInfos.put(file.getName() + s + "start",
											"activitiesGroup");

									newJob.getJobDataMap().put("data", start);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger = new CronTrigger();
									newTrigger.setName(file.getName() + s
											+ "startTrigger");
									try {
										newTrigger.setCronExpression(startTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob, newTrigger);

									// 结束时间
									JobDetail newJob1 = new JobDetail(file
											.getName()
											+ s + "end", "activitiesGroup",
											DoubleAwardActivityJob.class);
									jobInfos.put(file.getName() + s + "end",
											"activitiesGroup");

									newJob1.getJobDataMap().put("data", end);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger1 = new CronTrigger();
									newTrigger1.setName(file.getName() + s
											+ "endTrigger");
									try {
										newTrigger1.setCronExpression(endTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob1, newTrigger1);
								}
							}
						}
					}
				}
			} catch (SAXParseException err) {
				log.debug("** Parsing error" + ", line " + err.getLineNumber()
						+ ", uri " + err.getSystemId());
				log.debug(" " + err.getMessage());
				err.printStackTrace();
				throw new RuntimeException("双倍活动加载失败,请重启!");
			} catch (SAXException e) {
				Exception x = e.getException();
				((x == null) ? e : x).printStackTrace();
				throw new RuntimeException("双倍活动加载失败,请重启!");
			} catch (Throwable t) {
				t.printStackTrace();
				throw new RuntimeException("双倍活动加载失败,请重启!");
			}

			/************************ 加载[activities/onlineAward]下所有文件 *************************/
			try {

				File root = new File("activities/onlineAward");
				File[] files = root.listFiles();
				if (files != null) {
					for (File file : files) {
						if (!file.isFile()) {
							continue;
						}
						DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
								.newInstance();
						DocumentBuilder docBuilder = docBuilderFactory
								.newDocumentBuilder();
						Document doc = docBuilder.parse(file);
						doc.getDocumentElement().normalize();
						NodeList listOfNpc = doc.getElementsByTagName("在线有礼活动");
						log.debug("在线有礼活动 num = " + listOfNpc.getLength());

						for (int s = 0; s < listOfNpc.getLength(); s++) {
							Node firstNpcNode = listOfNpc.item(s);
							if (firstNpcNode.getNodeType() == Node.ELEMENT_NODE) {
								Element firstNpcElement = (Element) firstNpcNode;
								OnlineAwardInfo info = new OnlineAwardInfo();

								// 读取活动序号
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("活动序号");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										Integer num = Integer.parseInt(str);
										info.setId(num);
									}
								}

								String awardTime = null;
								// 读取送礼时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("送礼时间");
									if (node != null && node.getLength() > 0) {
										awardTime = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
									}
								}

								// 读取礼物类型
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("礼物类型");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setMoneyType(MmochatMoneyType
												.valueOf(str));
									}
								}

								// 读取礼物数量
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("礼物数量");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										Integer num = Integer.parseInt(str);
										info.setMoneyCount(num);
									}
								}

								// 读取系统消息
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("系统消息");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setSysMsg(str);
									}
								}

								// 读取玩家获奖消息
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("玩家获奖消息");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setUserMsg(str);
									}
								}

								// 装载定时任务
								if (awardTime != null) {
									// 开始时间
									JobDetail newJob = new JobDetail(file
											.getName()
											+ s + "awardTime",
											"activitiesGroup",
											OnlineAwardActivityJob.class);
									jobInfos.put(file.getName() + s
											+ "awardTime", "activitiesGroup");

									newJob.getJobDataMap().put("data", info);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger = new CronTrigger();
									newTrigger.setName(file.getName() + s
											+ "startTrigger");
									try {
										newTrigger.setCronExpression(awardTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob, newTrigger);
								}
							}
						}
					}
				}
			} catch (SAXParseException err) {
				log.debug("** Parsing error" + ", line " + err.getLineNumber()
						+ ", uri " + err.getSystemId());
				log.debug(" " + err.getMessage());
				err.printStackTrace();
				throw new RuntimeException("在线送礼活动加载失败,请重启!");
			} catch (SAXException e) {
				Exception x = e.getException();
				((x == null) ? e : x).printStackTrace();
				throw new RuntimeException("在线送礼活动加载失败,请重启!");
			} catch (Throwable t) {
				t.printStackTrace();
				throw new RuntimeException("在线送礼活动加载失败,请重启!");
			}

			/************************ 加载[activities/payAward]下所有文件 *************************/
			try {

				File root = new File("activities/payAward");
				File[] files = root.listFiles();
				if (files != null) {
					for (File file : files) {
						if (!file.isFile()) {
							continue;
						}
						DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
								.newInstance();
						DocumentBuilder docBuilder = docBuilderFactory
								.newDocumentBuilder();
						Document doc = docBuilder.parse(file);
						doc.getDocumentElement().normalize();
						NodeList listOfNpc = doc.getElementsByTagName("充值活动");
						log.debug("充值活动 num = " + listOfNpc.getLength());

						for (int s = 0; s < listOfNpc.getLength(); s++) {
							Node firstNpcNode = listOfNpc.item(s);
							if (firstNpcNode.getNodeType() == Node.ELEMENT_NODE) {
								Element firstNpcElement = (Element) firstNpcNode;
								MmochatPayAwardActivity start = new MmochatPayAwardActivity();
								MmochatPayAwardActivity end = new MmochatPayAwardActivity();
								String startTime = null, endTime = null;
								// 读取开始时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("开始时间");
									if (node != null && node.getLength() > 0) {
										startTime = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
									}
								}
								// 读取结束时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("结束时间");
									if (node != null && node.getLength() > 0) {
										endTime = node.item(0).getChildNodes()
												.item(0).getNodeValue().trim();
									}
								}
								// 读取开始系统消息
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("开始系统消息");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										start.setSystemMsg(str);
									}
								}
								// 读取结束系统消息
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("结束系统消息");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										end.setSystemMsg(str);
									}
								}
								// 读取K币兑换元宝比例
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("K币兑换元宝比例");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int rate = 100;
										try {
											rate = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
										}
										start.setExchangeRate(rate);
									}
								}
								// 装载定时任务
								if (startTime != null && endTime != null) {
									// 开始时间
									JobDetail newJob = new JobDetail(file
											.getName()
											+ s + "start", "activitiesGroup",
											PayAwardJob.class);
									jobInfos.put(file.getName() + s + "start",
											"activitiesGroup");

									newJob.getJobDataMap().put("data", start);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger = new CronTrigger();
									newTrigger.setName(file.getName() + s
											+ "startTrigger");
									try {
										newTrigger.setCronExpression(startTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob, newTrigger);

									// 结束时间
									JobDetail newJob1 = new JobDetail(file
											.getName()
											+ s + "end", "activitiesGroup",
											PayAwardJob.class);
									jobInfos.put(file.getName() + s + "end",
											"activitiesGroup");

									newJob1.getJobDataMap().put("data", end);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger1 = new CronTrigger();
									newTrigger1.setName(file.getName() + s
											+ "endTrigger");
									try {
										newTrigger1.setCronExpression(endTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob1, newTrigger1);
								}
							}
						}
					}
				}
			} catch (SAXParseException err) {
				log.debug("** Parsing error" + ", line " + err.getLineNumber()
						+ ", uri " + err.getSystemId());
				log.debug(" " + err.getMessage());
				err.printStackTrace();
				throw new RuntimeException("充值活动加载失败,请重启!");
			} catch (SAXException e) {
				Exception x = e.getException();
				((x == null) ? e : x).printStackTrace();
				throw new RuntimeException("充值活动加载失败,请重启!");
			} catch (Throwable t) {
				t.printStackTrace();
				throw new RuntimeException("充值活动加载失败,请重启!");
			}

			/************************ 加载[activities/firstPayAward]下所有文件 *************************/
			try {
				File root = new File("activities/firstPayAward");
				File[] files = root.listFiles();
				if (files != null) {
					for (File file : files) {
						if (!file.isFile()) {
							continue;
						}
						DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
								.newInstance();
						DocumentBuilder docBuilder = docBuilderFactory
								.newDocumentBuilder();
						Document doc = docBuilder.parse(file);
						doc.getDocumentElement().normalize();
						NodeList listOfNpc = doc.getElementsByTagName("首次充值活动");
						log.debug("首次充值活动 num = " + listOfNpc.getLength());

						for (int s = 0; s < listOfNpc.getLength(); s++) {
							Node firstNpcNode = listOfNpc.item(s);
							if (firstNpcNode.getNodeType() == Node.ELEMENT_NODE) {
								Element firstNpcElement = (Element) firstNpcNode;
								MmochatFirstPayAwardInfo firstPay = new MmochatFirstPayAwardInfo();
								String startTime = null, endTime = null;
								// 读取开始时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("开始时间");
									if (node != null && node.getLength() > 0) {
										startTime = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
									}
								}
								// 读取结束时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("结束时间");
									if (node != null && node.getLength() > 0) {
										endTime = node.item(0).getChildNodes()
												.item(0).getNodeValue().trim();
									}
								}

								// 最低等级要求
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("最低等级要求");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int level = 30;
										try {
											level = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
										}
										firstPay.setFirstPay_minLevel(level);
									}
								}
								// 读取活动时间描述
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("活动时间描述");
									if (node != null && node.getLength() > 0) {
										String timeInfo = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										firstPay.setFirstPay_timeInfo(timeInfo);
									}
								}

								// 道行奖励
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("道行奖励");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int dao = 0;
										try {
											dao = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
										}
										firstPay.setFirstPay_daoAward(dao);
									}
								}

								// 经验奖励
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("经验奖励");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int exp = 0;
										try {
											exp = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
										}
										firstPay.setFirstPay_expAward(exp);
									}
								}

								// 装载定时任务
								if (startTime != null && endTime != null) {
									// 开始时间
									JobDetail newJob = new JobDetail(file
											.getName()
											+ s + "start", "activitiesGroup",
											FirstPayAwardJob.class);
									jobInfos.put(file.getName() + s + "start",
											"activitiesGroup");

									firstPay.setFirstPay_open(true);
									newJob.getJobDataMap()
											.put("data", firstPay);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger = new CronTrigger();
									newTrigger.setName(file.getName() + s
											+ "startTrigger");
									try {
										newTrigger.setCronExpression(startTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob, newTrigger);

									// 结束时间
									JobDetail newJob1 = new JobDetail(file
											.getName()
											+ s + "end", "activitiesGroup",
											FirstPayAwardJob.class);
									jobInfos.put(file.getName() + s + "end",
											"activitiesGroup");

									newJob1.getJobDataMap().put("data",
											new MmochatFirstPayAwardInfo());

									// 创建trigger,触发定时程序
									CronTrigger newTrigger1 = new CronTrigger();
									newTrigger1.setName(file.getName() + s
											+ "endTrigger");
									try {
										newTrigger1.setCronExpression(endTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob1, newTrigger1);
								}
							}
						}
					}
				}

			} catch (SAXParseException err) {
				log.debug("** Parsing error" + ", line " + err.getLineNumber()
						+ ", uri " + err.getSystemId());
				log.debug(" " + err.getMessage());
				err.printStackTrace();
				throw new RuntimeException("充值活动加载失败,请重启!");
			} catch (SAXException e) {
				Exception x = e.getException();
				((x == null) ? e : x).printStackTrace();
				throw new RuntimeException("充值活动加载失败,请重启!");
			} catch (Throwable t) {
				t.printStackTrace();
				throw new RuntimeException("充值活动加载失败,请重启!");
			}

			/************************ 加载[activities/payLottery]下所有文件 *************************/
			try {

				File root = new File("activities/payLottery");
				File[] files = root.listFiles();
				if (files != null) {
					for (File file : files) {
						if (!file.isFile()) {
							continue;
						}
						DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
								.newInstance();
						DocumentBuilder docBuilder = docBuilderFactory
								.newDocumentBuilder();
						Document doc = docBuilder.parse(file);
						doc.getDocumentElement().normalize();
						NodeList listOfNpc = doc.getElementsByTagName("充值抽奖活动");
						log.debug("充值抽奖活动 num = " + listOfNpc.getLength());

						for (int s = 0; s < listOfNpc.getLength(); s++) {
							Node firstNpcNode = listOfNpc.item(s);
							if (firstNpcNode.getNodeType() == Node.ELEMENT_NODE) {
								Element firstNpcElement = (Element) firstNpcNode;
								MmochatPayLotteryInfo info = new MmochatPayLotteryInfo();

								// 读取活动序号
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("活动序号");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										Integer num = Integer.parseInt(str);
										info.setId(num);
									}
								}

								String startTime = null, midTime = null, endTime = null;
								// 读取开始统计时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("开始统计时间");
									if (node != null && node.getLength() > 0) {
										startTime = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
									}
								}

								// 读取停止统计并抽奖时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("停止统计并抽奖时间");
									if (node != null && node.getLength() > 0) {
										midTime = node.item(0).getChildNodes()
												.item(0).getNodeValue().trim();
									}
								}

								// 读取活动结束时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("活动结束时间");
									if (node != null && node.getLength() > 0) {
										endTime = node.item(0).getChildNodes()
												.item(0).getNodeValue().trim();
									}
								}

								// 读取充值最低人民币
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("充值最低人民币");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										Integer num = Integer.parseInt(str);
										info.setMoneyNeed(num);
									}
								}

								// 读取开始系统消息
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("开始系统消息");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setStartMsg(str);
									}
								}

								// 读取开奖系统消息
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("开奖系统消息");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setMidMsg(str);
									}
								}

								// 读取活动时间描述
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("活动时间描述");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setTimeInfo(str);
									}
								}

								// 读取礼物类型
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("礼物类型");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setMoneyType(MmochatMoneyType
												.valueOf(str));
									}
								}

								// 读取礼物数量
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("礼物数量");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										Integer num = Integer.parseInt(str);
										info.setMoneyAward(num);
									}
								}

								// 读取抽奖人数
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("抽奖人数");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										Integer num = Integer.parseInt(str);
										info.setLotteryNum(num);
									}
								}

								// 装载定时任务
								if (startTime != null && endTime != null
										&& midTime != null) {
									// 开始时间
									JobDetail newJob = new JobDetail(file
											.getName()
											+ s + "start", "activitiesGroup",
											PayLotteryJob.class);
									jobInfos.put(file.getName() + s + "start",
											"activitiesGroup");

									info.setState(MmochatPayLotteryState.开始统计);
									newJob.getJobDataMap().put("data", info);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger = new CronTrigger();
									newTrigger.setName(file.getName() + s
											+ "startTrigger");
									try {
										newTrigger.setCronExpression(startTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob, newTrigger);

									// 停止统计时间
									JobDetail newJob1 = new JobDetail(file
											.getName()
											+ s + "mid", "activitiesGroup",
											PayLotteryJob.class);
									jobInfos.put(file.getName() + s + "mid",
											"activitiesGroup");

									info = new MmochatPayLotteryInfo();
									info.setState(MmochatPayLotteryState.停止统计);
									newJob1.getJobDataMap().put("data", info);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger1 = new CronTrigger();
									newTrigger1.setName(file.getName() + s
											+ "midTrigger");
									try {
										newTrigger1.setCronExpression(midTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob1, newTrigger1);

									// 活动结束时间
									JobDetail newJob2 = new JobDetail(file
											.getName()
											+ s + "end", "activitiesGroup",
											PayLotteryJob.class);
									jobInfos.put(file.getName() + s + "end",
											"activitiesGroup");

									info = new MmochatPayLotteryInfo();
									info.setState(MmochatPayLotteryState.活动结束);
									newJob2.getJobDataMap().put("data", info);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger2 = new CronTrigger();
									newTrigger2.setName(file.getName() + s
											+ "endTrigger");
									try {
										newTrigger2.setCronExpression(endTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob2, newTrigger2);
								}
							}
						}
					}
				}
			} catch (SAXParseException err) {
				log.debug("** Parsing error" + ", line " + err.getLineNumber()
						+ ", uri " + err.getSystemId());
				log.debug(" " + err.getMessage());
				err.printStackTrace();
				throw new RuntimeException("在线送礼活动加载失败,请重启!");
			} catch (SAXException e) {
				Exception x = e.getException();
				((x == null) ? e : x).printStackTrace();
				throw new RuntimeException("在线送礼活动加载失败,请重启!");
			} catch (Throwable t) {
				t.printStackTrace();
				throw new RuntimeException("在线送礼活动加载失败,请重启!");
			}

			/************************ 加载[activities/payFastLottery]下所有文件 *************************/
			try {
				File root = new File("activities/payFastLottery");
				File[] files = root.listFiles();
				if (files != null) {
					for (File file : files) {
						if (!file.isFile()) {
							continue;
						}
						DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
								.newInstance();
						DocumentBuilder docBuilder = docBuilderFactory
								.newDocumentBuilder();
						Document doc = docBuilder.parse(file);
						doc.getDocumentElement().normalize();
						NodeList listOfNpc = doc
								.getElementsByTagName("即时充值抽奖活动");
						log.debug("即时充值抽奖活动 num = " + listOfNpc.getLength());

						for (int s = 0; s < listOfNpc.getLength(); s++) {
							Node firstNpcNode = listOfNpc.item(s);
							if (firstNpcNode.getNodeType() == Node.ELEMENT_NODE) {
								Element firstNpcElement = (Element) firstNpcNode;
								MmochatPayFastLotteryInfo info = new MmochatPayFastLotteryInfo();

								// 读取活动序号
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("活动序号");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										Integer num = Integer.parseInt(str);
										info.setId(num);
									}
								}

								String startTime = null, endTime = null;
								// 读取开始时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("开始时间");
									if (node != null && node.getLength() > 0) {
										startTime = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
									}
								}

								// 读取结束时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("结束时间");
									if (node != null && node.getLength() > 0) {
										endTime = node.item(0).getChildNodes()
												.item(0).getNodeValue().trim();
									}
								}

								// 读取系统消息
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("系统消息");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setStartMsg(str);
									}
								}

								// 读取充值条件
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("充值条件");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										Integer num = Integer.parseInt(str);
										info.setMoneyNeed(num);
									}
								}

								// 读取大奖面额
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("大奖面额");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										Integer num = Integer.parseInt(str);
										info.setBigValue(num);
									}
								}

								NodeList awardList = firstNpcElement
										.getElementsByTagName("奖品");
								for (int m = 0; m < awardList.getLength(); m++) {
									Node awardNode = awardList.item(m);
									if (awardNode.getNodeType() == Node.ELEMENT_NODE) {
										Element awardElement = (Element) awardNode;

										// 读取奖品类型
										MmochatMoneyType moneyType = null;
										// 读取奖品面额
										int money = 0;
										// 读取奖品数量
										int awardNum = 0;
										try {
											{
												NodeList node = awardElement
														.getElementsByTagName("奖品类型");
												if (node != null
														&& node.getLength() > 0) {
													String str = node.item(0)
															.getChildNodes()
															.item(0)
															.getNodeValue()
															.trim();
													moneyType = MmochatMoneyType
															.valueOf(str);
												}
											}

											{
												NodeList node = awardElement
														.getElementsByTagName("奖品面额");
												if (node != null
														&& node.getLength() > 0) {
													String str = node.item(0)
															.getChildNodes()
															.item(0)
															.getNodeValue()
															.trim();
													Integer num = Integer
															.parseInt(str);
													money = num;
												}
											}

											{
												NodeList node = awardElement
														.getElementsByTagName("奖品数量");
												if (node != null
														&& node.getLength() > 0) {
													String str = node.item(0)
															.getChildNodes()
															.item(0)
															.getNodeValue()
															.trim();
													Integer num = Integer
															.parseInt(str);
													awardNum = num;
												}
											}
										} catch (Exception e) {
											e.printStackTrace();
										}

										if (moneyType != null && money > 0
												&& awardNum > 0) {
											for (int c = 0; c < awardNum; c++) {
												MmochatFastLotteryAward award = new MmochatFastLotteryAward();
												award.setMoneyType(moneyType);
												award.setMoneyAward(money);
												info.getAwards().add(award);
											}
											MmochatFastLotteryAwardTitle award = new MmochatFastLotteryAwardTitle();
											award.setMoneyType(moneyType);
											award.setMoneyAward(money);
											award.setTotalNum(awardNum);
											info.getAwardTitle().add(award);
										}
									}
								}
								info.initAwardPool();// 对奖品进行乱序

								// 装载定时任务
								if (startTime != null && endTime != null) {
									// 开始时间
									JobDetail newJob = new JobDetail(file
											.getName()
											+ s + "start", "activitiesGroup",
											FastPayLotteryJob.class);
									jobInfos.put(file.getName() + s + "start",
											"activitiesGroup");

									info.setState(MmochatPayLotteryState.开始统计);
									newJob.getJobDataMap().put("data", info);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger = new CronTrigger();
									newTrigger.setName(file.getName() + s
											+ "startTrigger");
									try {
										newTrigger.setCronExpression(startTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob, newTrigger);

									// 活动结束时间
									JobDetail newJob2 = new JobDetail(file
											.getName()
											+ s + "end", "activitiesGroup",
											FastPayLotteryJob.class);
									jobInfos.put(file.getName() + s + "end",
											"activitiesGroup");

									MmochatPayFastLotteryInfo tmp = new MmochatPayFastLotteryInfo();
									tmp.setState(MmochatPayLotteryState.活动结束);
									newJob2.getJobDataMap().put("data", tmp);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger2 = new CronTrigger();
									newTrigger2.setName(file.getName() + s
											+ "endTrigger");
									try {
										newTrigger2.setCronExpression(endTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob2, newTrigger2);
								}
							}
						}
					}
				}

			} catch (SAXParseException err) {
				log.debug("** Parsing error" + ", line " + err.getLineNumber()
						+ ", uri " + err.getSystemId());
				log.debug(" " + err.getMessage());
				err.printStackTrace();
				throw new RuntimeException("在线送礼活动加载失败,请重启!");
			} catch (SAXException e) {
				Exception x = e.getException();
				((x == null) ? e : x).printStackTrace();
				throw new RuntimeException("在线送礼活动加载失败,请重启!");
			} catch (Throwable t) {
				t.printStackTrace();
				throw new RuntimeException("在线送礼活动加载失败,请重启!");
			}
			/************************ 加载[activities/daoActivity]下所有文件 *************************/
			try {
				File root = new File("activities/daoActivity");
				File[] files = root.listFiles();
				if (files != null) {
					for (File file : files) {
						if (!file.isFile()) {
							continue;
						}
						DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
								.newInstance();
						DocumentBuilder docBuilder = docBuilderFactory
								.newDocumentBuilder();
						Document doc = docBuilder.parse(file);
						doc.getDocumentElement().normalize();
						NodeList listOfNpc = doc.getElementsByTagName("刷道比赛");
						log.debug("刷道比赛活动 num = " + listOfNpc.getLength());

						for (int s = 0; s < listOfNpc.getLength(); s++) {
							Node firstNpcNode = listOfNpc.item(s);
							if (firstNpcNode.getNodeType() == Node.ELEMENT_NODE) {
								Element firstNpcElement = (Element) firstNpcNode;
								MmochatDaoActivity info = new MmochatDaoActivity();

								// 读取活动序号
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("活动序号");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										Integer num = Integer.parseInt(str);
										info.setId(num);
									}
								}

								String startTime = null, midTime = null, endTime = null;
								// 读取开始统计时间
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("开始统计时间");
									if (node != null && node.getLength() > 0) {
										startTime = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
									}
								}

								// 读取停止统计并展示结果
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("停止统计并展示结果");
									if (node != null && node.getLength() > 0) {
										midTime = node.item(0).getChildNodes()
												.item(0).getNodeValue().trim();
									}
								}

								// 读取展示结果结束
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("展示结果结束");
									if (node != null && node.getLength() > 0) {
										endTime = node.item(0).getChildNodes()
												.item(0).getNodeValue().trim();
									}
								}

								// 读取活动说明
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("活动说明");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setInfo(str);
									}
								}

								// 读取活动开始系统消息
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("活动开始系统消息");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setStartMsg(str);
									}
								}

								// 读取奖品类型
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("奖品类型");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										info.setMoneyType(MmochatMoneyType
												.valueOf(str));
									}
								}

								// 读取奖品数额
								{
									NodeList node = firstNpcElement
											.getElementsByTagName("奖品数额");
									if (node != null && node.getLength() > 0) {
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										String[] numList = str.split(",");
										for (int i = 0; i < numList.length; i++) {
											Integer num = Integer
													.parseInt(numList[i].trim());
											info.getMoneyAwards().add(num);
										}
									}
								}

								// 装载定时任务
								if (startTime != null && endTime != null
										&& midTime != null) {
									// 开始时间
									JobDetail newJob = new JobDetail(file
											.getName()
											+ s + "start", "activitiesGroup",
											DaoActivityJob.class);
									jobInfos.put(file.getName() + s + "start",
											"activitiesGroup");

									info.setState(MmochatPayLotteryState.开始统计);
									newJob.getJobDataMap().put("data", info);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger = new CronTrigger();
									newTrigger.setName(file.getName() + s
											+ "startTrigger");
									try {
										newTrigger.setCronExpression(startTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob, newTrigger);

									// 停止统计时间
									JobDetail newJob1 = new JobDetail(file
											.getName()
											+ s + "mid", "activitiesGroup",
											DaoActivityJob.class);
									jobInfos.put(file.getName() + s + "mid",
											"activitiesGroup");

									info = new MmochatDaoActivity();
									info.setState(MmochatPayLotteryState.停止统计);
									newJob1.getJobDataMap().put("data", info);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger1 = new CronTrigger();
									newTrigger1.setName(file.getName() + s
											+ "midTrigger");
									try {
										newTrigger1.setCronExpression(midTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob1, newTrigger1);

									// 活动结束时间
									JobDetail newJob2 = new JobDetail(file
											.getName()
											+ s + "end", "activitiesGroup",
											DaoActivityJob.class);
									jobInfos.put(file.getName() + s + "end",
											"activitiesGroup");

									info = new MmochatDaoActivity();
									info.setState(MmochatPayLotteryState.活动结束);
									newJob2.getJobDataMap().put("data", info);

									// 创建trigger,触发定时程序
									CronTrigger newTrigger2 = new CronTrigger();
									newTrigger2.setName(file.getName() + s
											+ "endTrigger");
									try {
										newTrigger2.setCronExpression(endTime);
									} catch (ParseException e) {
										e.printStackTrace();
									}

									// 通过trigger 调度job
									sched.scheduleJob(newJob2, newTrigger2);
								}
							}
						}
					}
				}
			} catch (SAXParseException err) {
				log.debug("** Parsing error" + ", line " + err.getLineNumber()
						+ ", uri " + err.getSystemId());
				log.debug(" " + err.getMessage());
				err.printStackTrace();
				throw new RuntimeException("刷道比赛加载失败,请重启!");
			} catch (SAXException e) {
				Exception x = e.getException();
				((x == null) ? e : x).printStackTrace();
				throw new RuntimeException("刷道比赛加载失败,请重启!");
			} catch (Throwable t) {
				t.printStackTrace();
				throw new RuntimeException("刷道比赛加载失败,请重启!");
			}

			/* 所有定时任务已加载，启动 */
			sched.start();
		} catch (SchedulerException e) {
			e.printStackTrace();
		}

	}

}
